class_name GameplayAttribute
extends Resource

##
signal base_value_changed(old: float, new: float)

##
signal current_value_changed(old: float, new: float)

##
@export var attribute_name: String

##
@export var min_value: float

##
@export var max_value: float

##
@export var base_value: float :
	set(value):
		var old = base_value
		base_value = clampf(value, min_value, max_value)
		base_value_changed.emit(old, base_value)
		current_value = base_value

##
@export var current_value: float :
	set(value):
		var old = current_value
		current_value = clampf(value, min_value, max_value)
		current_value_changed.emit(old, current_value)


func scale(weight: float):
	current_value *= weight


func reset() -> void:
	current_value = base_value


func to_max() -> void:
	current_value = max_value


func to_min() -> void:
	current_value = min_value
